package com.bw.home.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import com.bw.home.R
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class DanMuDialogFragment : BottomSheetDialogFragment() {
    lateinit var et_danmu_home: EditText
    lateinit var iv_danmu_home: ImageView

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = layoutInflater.inflate(R.layout.view_danmu, container, false)
        initView(view)
        return view
    }

    fun initView(view: View) {
        et_danmu_home = view.findViewById(R.id.et_danmu_content_cinema)
        iv_danmu_home = view.findViewById(R.id.iv_danmu_send_cinema)
        iv_danmu_home.setOnClickListener {
            if (danMuListener != null) {
                danMuListener.onClick()
            }
        }
    }

    fun close() {
        dismiss()
    }

    //定义接口  1
    interface DanMuListener {
        fun onClick()
    }

    //2
    private lateinit var danMuListener: DanMuListener

    //3
    fun setDanMuListener(danMuListener: DanMuListener) {
        this.danMuListener = danMuListener
    }
}